<?php
  
  //db::sqlExec("delete from page where _url='/daten-erfassung-team'");
  
  
  
  $scaffolding = new scaffolding();
  $scaffolding->table = "[php_property:table]";
  $scaffolding->tableOrderby = "[php_property:table_orderby]";
  $scaffolding->tableField = "[php_property:field]";
  $scaffolding->tableFieldTitle = "[php_property:field_title]";
  
  $table = "[php_property:table]";
  //$tableTable = "[php_property:table_table]";
  
  $tableField = "[php_property:table_field]";
  
  
  //$newItem = strtolower("[php_property:new_item]");
  //$editItem = strtolower("[php_property:edit_item]");
  
  
  $newItemTmp = strtolower("[php_property:new_item]");
  $newItem = false;
  if (($newItemTmp == "true") or ($newItemTmp == "on"))   
    $newItem = true;
  
  
  $editItemTmp = strtolower("[php_property:edit_item]");
  $editItem = false;
  if (($editItemTmp == "true") or ($editItemTmp == "on"))   
    $editItem = true;
    
  $tableSearchTmp = strtolower("[php_property:table_search]");
  $tableSearch = false;
  if (($tableSearchTmp == "true") or ($tableSearchTmp == "on"))   
    $tableSearch = true;
    
  
  
  
  $deleteItemTmp = strtolower("[php_property:delete_item]");
  $deleteItem = false;
  if (($deleteItemTmp == "true") or ($deleteItemTmp == "on"))   
    $deleteItem = true;

  
  
  
  $formTable = "[php_property:form_table]";
  $formField = "[php_property:form_field]";
  
  $formSearchindexTmp = "[php_property:form_searchindex]";
  $formSearchindex = false;  
  if (($formSearchindexTmp == "true") or ($formSearchindexTmp == "on")) 
    $formSearchindex = true;
    
  
  
  
  
  $fieldType = "[php_property:field_type]";
  $redirect = $this->pageUrl; // "[php_property:redirect]";
  

  
  $tmp = "";
  $formUrl = "";
  
  
  //if (($newItem == "true") or ($editItem == "true")) {
  if ($newItem) {
  
    $htmlForm = $scaffolding->createForm($formTable, $formField, "", $fieldType, $redirect, $formSearchindex);
 
    //echo $htmlForm;
    
    //echo "SELECT _template FROM page WHERE id={$this->pageId}";
    $templateId = db::getValue("SELECT __template FROM page WHERE id={$this->pageId}");
    $template = db::getValue("SELECT template FROM _template WHERE id=$templateId");
    
    
    
    $formUrl = page::createPage("Daten Erfassung $table", $htmlForm, $this->pageUrl, false, 0, 30, true, "", $template);
    $tmp = $scaffolding->addNewItem($formUrl);        
  
  }
  
  $htmlTableSeearch = "";
  if ($tableSearch) {
        $htmlTableSeearch = component::getCom("form_search");       
  }
  
  
  


//  $htmlForm = $htmlForm.$this->pageUrl;  
    
    
  //$scaffolding->createModul();
  $tmp = $tmp.$scaffolding->createTable2($table, $tableField, $editItem, $deleteItem, $formUrl, $tableSearch);
  
  $tmp = $htmlTableSeearch.$tmp;
  
  //$scaffolding->createForm();
  
  
  
  
  
  
  
  $body = str_ireplace("[replace]", $tmp, $body);
  
  
?>
